Password prompts continue after adding NOPASSWD for user in /etc/sudoers

Added my userid to /etc/sudoers so I could sudo without password prompts, but password prompts continued. This is because my userid was also member of the "sudo" group, which didn't have the NOPASSWD clause:

sudo sed -n /^[a-z%]/p /etc/sudoers
root	ALL=(ALL:ALL) ALL
myuid   ALL=NOPASSWD: ALL
%sudo	ALL=(ALL:ALL) ALL

This must be a common problem people have because authors of the sudoers manual page, put the reason right in the description. 🙂

man sudoers

When multiple entries match for a user, they are applied in order. Where there are multiple matches, the last match is used (which is not necessarily the most specific match).

So the solution could be any of the following:

  • Remove my user from the sudo group
  • Add the NOPASSWD clause to the sudo group entry
  • Place my user entry after the sudo entry

Whichever method is chosen, must remember to log out of the X session for changes to take effect!

1 Comment

  • 1. Koray replies at 12th November 2011, 3:18 pm :

    I simply changed this line

    %admin ALL=(ALL) ALL to %admin ALL=(ALL) NOPASSWD: ALL

    That’s solved problems for all users.

Leave a comment

NOTE: Enclose quotes in <blockquote></blockquote>. Enclose code in <pre lang="LANG"></pre> (where LANG is one of these).